🔍 Docker Log Analysis 101¶
![]()
🔍 GREP: Search for Specific Logs¶
To search for specific entries (e.g., by date), use grep. Using 2>&1 ensures both stdout and stderr are included:
docker logs <container_id> 2>&1 | grep "2024-06-20"
📌 Tip: You can also pipe into less for easier navigation:
docker logs <container_id> 2>&1 | less
📄 TAIL: View Recent Logs¶
you can use the tail option to specify the number of logs you want to see
docker logs --tail 100 <container_id>
You can combine this with -f to follow logs in real-time:
tail -f /var/lib/docker/containers/<container_id>/<container_id>-json.log
📂 Access Log Files Directly (Live Tailing)¶
If your Docker engine is using the default json-file logging driver, logs are stored here:
/var/lib/docker/containers/<container_id>/<container_id>-json.log
Live tail the log file directly:
sudo tail -f /var/lib/docker/containers/<container_id>/<container_id>-json.log